#!/bin/bash
echo "" > ip_list.txt
echo "" > port_img_list.txt
loop=0
while [ "115" -ne "$loop" ]
do
	loop=`expr $loop + 1`
	echo $loop
	links2 -dump http://www.hidemyass.com/proxy-list/All-Countries/fast/show-planetlab/$loop/ | grep "port" | sed -e 's/[ ]*PlanetLab Proxy//g' -e 's/^[ ]*//g' -e 's/[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}//g' | awk '{print$1}' >> ip_list.txt
	links2 -source http://www.hidemyass.com/proxy-list/All-Countries/fast/show-planetlab/$loop/ | grep "/proxy-list/port.php?server=" | sed -e 's/<td><img src="//g' -e 's/"//g' | awk -F '&' '{print$1}' >> port_img_list.txt
	echo "Number of hosts: `grep . -c ip_list.txt`"
	echo "Number of ports: `grep / -c port_img_list.txt`"
	echo
done

#grep / -c port_img_list.txt
#grep '[0-9]' -c ip_list.txt
loop=1000
while read img
do
	echo "Scan: http://www.hidemyass.com$img"
	wget -t 5 -O img/$loop.png http://www.hidemyass.com$img &
	loop=`expr $loop + 1`
done < port_img_list.txt
#for i in img/*
#do
#	gocr -C 0-9 -i $i >> port_list.txt
#done
#paste -d: ip_list.txt port_list.txt > proxy_list.txt
#for i in `cat $1`
#do
#	echo "$i"
#	-links2 -http-proxy $i -dump http://www.auto-reanimator.ru/
#done

